

//
//  HMStatusToolbar.m
//  黑马微博-wzy
//
//  Created by Mac on 2017/2/14.
//  Copyright © 2017年 Mac. All rights reserved.
//

#import "HMStatusToolbar.h"

@interface HMStatusToolbar()
//分割线
@property (nonatomic, strong) NSMutableArray *dividers;

@end


@implementation HMStatusToolbar
- (NSMutableArray *)dividers{
    if (_dividers == nil) {
        self.dividers = [NSMutableArray array];
    }
    return _dividers;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //设置分割线
        [self setupDivider];
    }
    return self;
}

- (void)setupDivider{

    UIImageView *divider = [[UIImageView alloc] init];
    divider.image = [UIImage imageWithName:@"timeline_card_bottom_line"];
    divider.contentMode = UIViewContentModeCenter;
    [self addSubview:divider];
    
    [self.dividers addObject:divider];

}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    int dividerCount = (int)self.dividers.count;
    
    CGFloat dividerFirstX = self.width / (dividerCount);
    CGFloat dividerH = self.height;
    
    //设置分割线的frame
    for (int i = 0; i < dividerCount; i++ ) {
        UITableView *divider = self.dividers[i];
        divider.width = 4;
        divider.height = dividerH;
        divider.centerX = (i + 1) * dividerFirstX;
        divider.centerY = dividerH * 0.5;
    }
}


- (void)drawRect:(CGRect)rect{

    [[UIImage resizedImage:@"common_card_bottom_background"] drawInRect:rect];
}


@end
